from myelin.server.nodetype.Events import EventHandler
from myelin.Ns import MYELIN, DC, DCTERMS
from myelin.rdf.Ns import RDF_TYPE
from myelin.rdf.bindery.Model import OBJECT_TYPE_RESOURCE, OBJECT_TYPE_LITERAL

from Document import Document


class Document(Document):
        
    def createHead(self, context, obj):
                
        acct = context.account
        action = context.action
        actionType = context.nodeType.actions[action]
        
        obj['type'] = actionType.classTypes
        
        obj.update({
            'action' : action,
            'publisher' : context.defaults.domain_uri,
            'created' : self.newDateTimeString(
                context.session.dateTime
            ),
            'identifier' : self.newUri(),
        })
            
        if acct.isAgent():
            obj['requestor'] = acct.agentId
            
        return obj
    

class EventHandler(EventHandler):
    
    newDocument = Document
